<template>
  <div class="app-container">
    <!--    隐藏域 记录id-->
    <input type="hidden" v-model="userdetail.id"/>

    <el-form ref="form" :model="userdetail" label-width="120px">

      <el-form-item label="身份证">
        <el-input v-model="userdetail.idcard"/>
      </el-form-item>
      <el-form-item label="描述">
        <el-input v-model="userdetail.description"/>
      </el-form-item>
      <el-form-item label="生日">
        <el-input v-model="userdetail.birth"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">修改</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  data() {
    return {
      userdetail: {
        id: 0,
        uid: 0,
        idcard: '',
        description: '',
        birth: ''
      }
    }
  },
  mounted() {
    this.userdetail = this.$store.state.user.userdetail;
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url: "http://127.0.0.1:8080/api/user/userdetial/update.do",
        method: "POST",
        data: this.userdetail
      }).then(res => {
        if (res.code == 0) {
          //跳转到列表页面
          this.$router.push("/usersearch");
        }
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line {
  text-align: center;
}
</style>

